/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 解析.node.node;

import 解析.Matcher;

/**
 *
 * @author yanxi
 */
public class Begin extends Node {

    @Override
    public boolean match(Matcher matcher, int i, CharSequence seq) {
        int fromIndex = (matcher.anchoringBounds) ? matcher.from : 0;
        if (i == fromIndex && next.match(matcher, i, seq)) {
            matcher.first = i;
            matcher.groups[0] = i;
            matcher.groups[1] = matcher.last;
            return true;
        } else {
            return false;
        }
    }
    
    @Override
    public String toString(){
        return "^";
    }
}
